# -*- coding: utf-8 -*-
# @Time : 2022/6/17 14:29
# @Author : 王森
# @Email : wayne_lau@aliyun.com
# @File : url.py
# @Project : syl
from flask import Flask
from flask_restful import Api
from flask_cors import CORS
from common.models import db
from apps.user import user_bp
from apps.oauth_user import oauth_user_bp
from apps.course import course_bp
from apps.comment import comment_bp
from apps.vip import vip_bp
from apps.pay import pay_bp
from apps.pathes import path_bp


def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    # 初始化数据
    db.init_app(app)
    cors = CORS(app)

    # 注册蓝图
    app.register_blueprint(user_bp)
    app.register_blueprint(oauth_user_bp)
    app.register_blueprint(course_bp)
    app.register_blueprint(comment_bp)
    app.register_blueprint(vip_bp)
    app.register_blueprint(pay_bp)
    app.register_blueprint(path_bp)


    return app